<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="客户管理">
<div class="xm-product">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a class="back">返回上一级</a>
            </div>
            <div class="panel-body demo-content">
                <form id="addForm" class="form-horizontal" action="${basepath}/rest/manage/contract/insertContract"
                      method="post">
                    <input type="hidden" name="customerID" value="">
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            客户名称：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" id="customerName"
                                  disabled/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            委托书(甲方)：
                        </label>
                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="client"
                                   data-rules="{required : true}" placeholder="请填写委托方(甲方)">
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">
                            付款条件：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="payCondition" placeholder="请填写付款条件">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            项目名称：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="name" placeholder="请填写项目名称"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            附件信息：
                        </label>

                        <div class="controls">
                            <input type="text" class="input-normal control-text" name="fileUrl"
                                   data-rules="{required : true}" readonly>
                            <a id="uploadBtn" class="button button-min button-primary pull-right"
                               style="height:32px;margin-left: 10px;padding: 0px;">上传附件</a>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            合同金额：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="contractMoney" placeholder="请填写合同金额"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            预付款：
                        </label>
                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="contractPayMoney" placeholder="请填写预付款"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            签订日期：
                        </label>
                        <div class="controls bui-form-group-select">
                            <input type="text" class="calendar" name="contractTime" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            备注说明：
                        </label>
                        <div class="controls  control-row-auto">
                            <textarea   name="remark" placeholder="请输入内容"
                                      style="width: 400px;"></textarea>
                        </div>
                    </div>
                    <div class="centered">
                        <button type="submit" class="button  button-large  button-success">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var postData = GetRequest(),
            customerID=postData.customerID,//从客户管理列表获取取customerID
            customerName=postData.customerName;//从客户管理列表获取取customerName
    $("input[type='hidden']").val(customerID);
    $("#customerName").val(customerName);
    $(".back").attr('href','${basepath}/rest/manage/contract/toList?customerID='+customerID+'&customerName='+customerName+'');
    var addForm = new BUI.Form.Form({
        srcNode: '#addForm',
        submitType: 'ajax',
        callback: function (data) {
            if (data.success == true) {
               window.location.href='${basepath}/rest/manage/contract/toList?customerID='+customerID+'&customerName='+customerName+'';
            } else {
                BUI.Message.Alert(data.message, 'error');
                return;
            }
        }
    }).render();
    //附件上传
    var fileuploader = WebUploader.create({
        auto: true,
        swf: '${staticpath}/common/ueditor/third-party/webuploader/Uploader.swf',
        server: '${basepath}/rest/manage/ued/uploadFile',
        pick: '#uploadBtn',
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        //设置事件监听超时时间，0表示不设置超时时间
        timeout: 30 * 60 * 1000,
        resize: false,
        //上传并发数
        threads: 1,
        accept: {
            title: 'file',
            extensions: 'jpg,mp4,pdf,png,ppt,doc,xls,docx,xlsx,pptx',
            mimeTypes: 'image/jpeg,video/mp4,application/pdf,image/png,application/vnd.ms-powerpoint,application/msword,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation'
        }
    });
    fileuploader.on('uploadSuccess', function (file, data) {
        fileuploader.removeFile(file);
        addForm.setFieldValue("fileUrl", data.data);
    });
</script>

</@page.pageBase>
